package com.infocollect.project.grant.controller;

import java.util.List;

import com.infocollect.common.utils.StringUtils;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.infocollect.framework.aspectj.lang.annotation.Log;
import com.infocollect.framework.aspectj.lang.enums.BusinessType;
import com.infocollect.project.grant.domain.TappAuditReson;
import com.infocollect.project.grant.service.ITappAuditResonService;
import com.infocollect.framework.web.controller.BaseController;
import com.infocollect.framework.web.domain.AjaxResult;
import com.infocollect.common.utils.poi.ExcelUtil;
import com.infocollect.framework.web.page.TableDataInfo;

/**
 * 审核原因配置Controller
 * 
 * @author infocollect
 * @date 2022-11-06
 */
@RestController
@RequestMapping("/grant/auditreson")
public class TappAuditResonController extends BaseController
{
    @Autowired
    private ITappAuditResonService tappAuditResonService;

    /**
     * 查询审核原因配置列表
     */
    @PreAuthorize("@ss.hasPermi('grant:auditreson:list')")
    @GetMapping("/list")
    public TableDataInfo list(TappAuditReson tappAuditReson)
    {
        startPage();
        List<TappAuditReson> list = tappAuditResonService.selectTappAuditResonList(tappAuditReson);
        return getDataTable(list);
    }
    /**
     * 查询审核原因配置列表
     */
    @GetMapping("/auditreasonListall")
    public AjaxResult auditreasonListall(TappAuditReson tappAuditReson)
    {
        if(StringUtils.isAnyEmpty(tappAuditReson.getTablename())){
            return AjaxResult.error("错误的请求，没有表单信息");
        }
        List<TappAuditReson> list = tappAuditResonService.selectTappAuditResonList(tappAuditReson);
        return AjaxResult.success(list);
    }
    /**
     * 导出审核原因配置列表
     */
    @PreAuthorize("@ss.hasPermi('grant:auditreson:export')")
    @Log(title = "审核原因配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TappAuditReson tappAuditReson)
    {
        List<TappAuditReson> list = tappAuditResonService.selectTappAuditResonList(tappAuditReson);
        ExcelUtil<TappAuditReson> util = new ExcelUtil<TappAuditReson>(TappAuditReson.class);
        return util.exportExcel(list, "auditreson");
    }

    /**
     * 获取审核原因配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('grant:auditreson:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tappAuditResonService.selectTappAuditResonById(id));
    }

    /**
     * 新增审核原因配置
     */
    @PreAuthorize("@ss.hasPermi('grant:auditreson:add')")
    @Log(title = "审核原因配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TappAuditReson tappAuditReson)
    {
        return toAjax(tappAuditResonService.insertTappAuditReson(tappAuditReson));
    }

    /**
     * 修改审核原因配置
     */
    @PreAuthorize("@ss.hasPermi('grant:auditreson:edit')")
    @Log(title = "审核原因配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TappAuditReson tappAuditReson)
    {
        return toAjax(tappAuditResonService.updateTappAuditReson(tappAuditReson));
    }

    /**
     * 删除审核原因配置
     */
    @PreAuthorize("@ss.hasPermi('grant:auditreson:remove')")
    @Log(title = "审核原因配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tappAuditResonService.deleteTappAuditResonByIds(ids));
    }
}
